import * as echarts from 'echarts';
import chinaMapData from '../data/china.json';
//注册中国地图
echarts.registerMap('china', chinaMapData);
export function useEchart(el: HTMLElement) {
  const echartInstance = echarts.init(el);
  const setOptions = function (options: echarts.EChartsOption) {
    echartInstance.setOption(options);
  };
  const setResize = function () {
    echartInstance.resize();
  };
  window.addEventListener('resize', () => {
    echartInstance.resize();
  });
  return {
    echartInstance,
    setOptions,
    setResize
  };
}
